package org.ligson.cg;

import org.apache.commons.cli.*;

import java.util.Arrays;

public class CpTest {
    private static Options options = new Options();

    private static void help() {
        // This prints out some help
        HelpFormatter formater = new HelpFormatter();
        formater.printHelp("Main", options);
        System.exit(0);
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(args));
        CommandLineParser parser = new DefaultParser();
        // create Options object
        Option createAppOpt = Option.builder().numberOfArgs(2).argName("ce").longOpt("create-entity").hasArg().desc("生成实体")
                .argName("t").longOpt("type").hasArg().optionalArg(true).desc("类型").build();
        //new Option("ce", "create-entity", true, "display current time(boolean)")
        options.addOption(createAppOpt);
        //options.addOption(new Option("ca", "create-app", true, "use given information(String)"));
        //options.addOption(createAppOpt);
        options.addOption(new Option("h", "help", true, "use given size(Integer)"));
        try {
            CommandLine line = parser.parse(options, args);
            if (line.hasOption("help")) {
                String value = line.getOptionValue("help");
                System.out.println("help value:" + value);
                help();
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
